#! /bin/bash
#
# AGREGAR DESCRIPCION
#-------------------------------------------------------------------------
# Author:   Andres Medina
#	    Hernan Barrios
#-------------------------------------------------------------------------
# Last updated on : 22-December-2011
# 
#-------------------------------------------------------------------------

#			MAIN PROGRAM
#------------------------------------------------------------------------
# Check if the number of arguments is correct
if  [ $# != 3 ]; then
  echo "Error: wrong number of arguments. Try using 'rtdelay <host> <n> <max_size>'"
  exit 1;
fi

# Set the host name, measurements number, the max size of the package and the timeout time
HOST=$1
MEASUREMENTS_NUM=$2
MAX_SIZE=$3
TIMEOUT=$((2*$MEASUREMENTS_NUM))

# Makes ping to the Host until 'n' packets are received or the timeout is reached
ping $1 -c $MEASUREMENTS_NUM -w $TIMEOUT

# If the status of the ping command exits with 1 it means that the timeout is hit
if [ $? == 1 ]; then
  echo "ERROR: Timeout! host not reachable";
fi




